import { createStorage } from "@/utils/Storage";

export const ResultStorage = createStorage({
  prefixKey: 'RESULT_',
  storage: sessionStorage,
})

export type ResultType = {
  status: 'success' | 'error' | 'warning' | 'info',
  title: string,
  description: string,
  content: string,
  createTime: number
}

export const setInfo = (result: ResultType) => {
  ResultStorage.set('info', result)
}

export const getInfo = () => {
  return ResultStorage.get('info', {
    status: 'error',
    title: '操作失败',
    description: '未接收到需要处理的结果',
    content: '请勿随意访问, 请返回首页',
    createTime: Date.now()
  }) as ResultType
}
